Skip to content

test: improve frontend coverage 26% → 70%#81

Merged
thedavidweng merged 7 commits into
mainfrom
test/improve-coverage
Jun 16, 2026
Merged

test: improve frontend coverage 26% → 70%#81
thedavidweng merged 7 commits into
mainfrom
test/improve-coverage

Conversation

@thedavidweng

Copy link
Copy Markdown
Owner

Summary

Improve frontend test coverage from 26.04% to 69.73% lines (499 → 1348 covered lines). 801 tests, all passing.

New test files (11)

File Covers
model-slice.test.ts Store model slice (model pack selection, download, bootstrap)
settings-slice.test.ts Store settings slice (get/set/reset, device info)
api.test.ts Tauri command wrappers (invoke mocking)
diagnostics.test.ts Diagnostics utility
window-shell.test.ts Window shell state management
playback-bar.test.tsx PlaybackBar (play/pause, seek, volume, track switching)
toast.test.tsx Toast notification (render, dismiss)
bootstrap-banners.test.tsx DemoBanner, ModelBootstrapBanner, UpdateBanner
generation-panel-subcomponents.test.tsx FormBody, Header, ActionFooter, shared utils
settings-components.test.tsx SetupScreen, SettingsOverlay
layout-components.test.tsx AppLayout, MainContentView, OpenLoopStage, SidebarRail, Toolbar, WindowChrome

Expanded test files (3)

  • store-slices.test.ts — generation and history slice gap coverage
  • app-shortcuts.test.ts — uncovered branches
  • prompt-examples.test.ts — uncovered code paths

Test plan

  • All 801 tests pass (pnpm vitest run)
  • Coverage thresholds met (pnpm vitest run --coverage)
  • No excluded files tested (types, barrel files, i18n, main.tsx)
  • Codecov CI passes on this PR

Add 11 new test files and expand 3 existing ones covering:
- Store slices: model, settings, generation, history gaps
- Lib: api, diagnostics, window-shell, app-shortcuts, prompt-examples gaps
- Components: PlaybackBar, Toast, bootstrap banners, GenerationPanel sub-components, settings screens, layout components

801 tests, all passing. Coverage jumps from 26.04% to 69.73% lines.
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds 11 new test files and expands 3 existing ones to improve frontend line coverage from ~26% to ~70%, plus a one-line CI fix that downgrades codecov/test-results-action from @v5 to @v1.

  • New test files cover the Zustand store slices (model, settings, generation, history), all Tauri API wrappers, diagnostic utilities, window-shell state logic, and the major UI components (PlaybackBar, Toast, bootstrap banners, generation panel subcomponents, layout components, and settings screens).
  • Existing test files (store-slices.test.ts, app-shortcuts.test.ts, prompt-examples.test.ts) are expanded with gap-coverage for previously untested branches.
  • The CI workflow changes codecov/test-results-action@v5@v1; the separate codecov/codecov-action pin is untouched.

Confidence Score: 5/5

All changes are additive test code and a one-line CI action version fix; no production logic is modified.

Every changed file is either a new or expanded test file, or the CI workflow where the only edit corrects a wrong major-version tag on the Codecov test-results upload step. No store slices, components, or API wrappers were modified. The test assertions were verified against the actual source implementations and are accurate throughout.

The CI workflow change (codecov/test-results-action version) is worth a quick sanity-check that Codecov CI actually passes after merge, as that checkbox was left unchecked in the PR description.

Important Files Changed

Filename Overview
.github/workflows/ci.yml Downgrades codecov/test-results-action from @v5 to @v1; likely correcting a wrong major-version reference since test-results-action only ships v1.
tests/unit/model-slice.test.ts Thorough tests for model pack selection, download/delete, bootstrap status transitions, and Tauri vs preview-mode paths. Assertions align with the actual model-packs.ts logic.
tests/unit/settings-slice.test.ts Covers addRecentPrompt, toggleFavoritePrompt, removeRecentPrompt, setLanguage, completeSetup, hydrateFromPersistence, and device-info hydration with correct assertions and isolation.
tests/unit/store-slices.test.ts Expands existing generation/history slice tests with deleteGenerationRecord, clearGenerationHistory, loadGenerationSettings, cancelGeneration, batch operations, and resumeActiveTask scenarios.
tests/unit/playback-bar.test.tsx Covers PlaybackBar with no track, with a loaded track, play/pause, seek, volume, track switching, and compare mode. Module-level getBoundingClientRect override is class-scoped and safe within the worker.
tests/unit/layout-components.test.tsx Tests WindowChrome, Toolbar, SidebarRail (including drag resize), MainContentView, OpenLoopStage, and AppLayout; uses vi.hoisted to patch jsdom's missing setPointerCapture before imports.
tests/unit/settings-components.test.tsx Tests SetupScreen and SettingsOverlay rendering, tab navigation, section switches, and danger-zone confirmations with well-isolated component mocks.
tests/unit/api.test.ts New file; exercises every Tauri invoke wrapper with correct argument shapes including null-query normalization for listGenerations.
tests/unit/window-shell.test.ts Tests getDefaultWindowShellState, resolveWindowShellState (including guard against zero/negative/NaN/Infinity values), createWindowShellStyle, and the useWindowShellState hook including cancellation on unmount.
tests/unit/bootstrap-banners.test.tsx Tests DemoBanner, ModelBootstrapBanner, and UpdateBanner render and interaction paths; minor use of 'small' as modelVariant (invalid enum value) but doesn't affect correctness given the loose storeState typing.
tests/unit/generation-panel-subcomponents.test.tsx Covers FieldError, FieldLabel, FilePickerField, handleTextFieldChange, Header, FormBody, and ActionFooter with realistic props and interaction tests.
tests/unit/diagnostics.test.ts Verifies collectDiagnostics and formatDiagnostics guard on TAURI_INTERNALS, invoke call, error propagation, and pretty-print output.
tests/unit/toast.test.tsx Covers Toast render, dismiss, action button, auto-close with fake timers, custom duration, and timer cleanup on unmount.
tests/unit/app-shortcuts.test.ts Expands coverage with getShortcutPlatform (all platforms including SSR), getShortcutDisplay, isInputFocused (input/textarea/select/contentEditable), and matchesShortcut branch tests.
tests/unit/prompt-examples.test.ts Expands coverage for uncovered code paths in prompt-examples.ts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph StoreSlices["Store Slices (unit tested)"]
        MS[model-slice.test.ts]
        SS[settings-slice.test.ts]
        GS[store-slices.test.ts]
    end
    subgraph Utilities["Utilities (unit tested)"]
        API[api.test.ts]
        WS[window-shell.test.ts]
        DX[diagnostics.test.ts]
        AS[app-shortcuts.test.ts]
    end
    subgraph Components["UI Components (unit tested)"]
        PB[playback-bar.test.tsx]
        BB[bootstrap-banners.test.tsx]
        GP[generation-panel-subcomponents.test.tsx]
        LC[layout-components.test.tsx]
        SC[settings-components.test.tsx]
        TT[toast.test.tsx]
    end
    CI[.github/workflows/ci.yml]
    StoreSlices --> Components
    Utilities --> StoreSlices
    CI -.->|uploads JUnit results| StoreSlices
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph StoreSlices["Store Slices (unit tested)"]
        MS[model-slice.test.ts]
        SS[settings-slice.test.ts]
        GS[store-slices.test.ts]
    end
    subgraph Utilities["Utilities (unit tested)"]
        API[api.test.ts]
        WS[window-shell.test.ts]
        DX[diagnostics.test.ts]
        AS[app-shortcuts.test.ts]
    end
    subgraph Components["UI Components (unit tested)"]
        PB[playback-bar.test.tsx]
        BB[bootstrap-banners.test.tsx]
        GP[generation-panel-subcomponents.test.tsx]
        LC[layout-components.test.tsx]
        SC[settings-components.test.tsx]
        TT[toast.test.tsx]
    end
    CI[.github/workflows/ci.yml]
    StoreSlices --> Components
    Utilities --> StoreSlices
    CI -.->|uploads JUnit results| StoreSlices
Loading

Fix All in Claude Code Fix All in Codex Fix All in Cursor

Reviews (6): Last reviewed commit: "fix: stub setPointerCapture for jsdom in..." | Re-trigger Greptile

Comment thread tests/unit/playback-bar.test.tsx Outdated
Comment thread tests/unit/prompt-examples.test.ts Outdated
- Fix taskType "text-to-audio" → "text2music" in playback-bar test
- Derive TOTAL_EXAMPLES from PROMPT_CATEGORIES.length instead of hardcoding
- Fix codecov/test-results-action version v5 → v1 (v5 doesn't exist)
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

- Add missing vitest imports (settings-slice, toast)
- Remove unused imports (layout-components, window-shell)
- Fix GenerationFormValues mock to include all required fields
- Fix mock type casts (store mock, DeviceInfo null)
- Fix TimeSignature "4/4" → "4", play() return type
- Fix CSSProperties custom property access
- Fix spread argument types in mock factories
@thedavidweng thedavidweng merged commit a0b6013 into main Jun 16, 2026
12 checks passed
@thedavidweng thedavidweng deleted the test/improve-coverage branch June 16, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant